package com;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class ReceiveData {
    public static void main(String[] args) throws IOException {
        DatagramSocket     dgs=new DatagramSocket(10086);
        //创建一个数据包用于接受数据
        byte[] bytes=new byte[1024];
        DatagramPacket  dp=new DatagramPacket(bytes,bytes.length);
        dgs.receive(dp);
        //解析数据包
        byte[] data = dp.getData();
        int len = dp.getLength();
        String  s=new String(data,0,len);
        System.out.println(s);
      dgs.close();
    }
}
